import graphene
from flask import Flask
from flask_graphql import GraphQLView
import datetime
import decimal
class Query(graphene.ObjectType):
    str_= graphene.String()
    int_ = graphene.Int()
    float_ = graphene.Float()
    boolean_ = graphene.Boolean()
    id_ = graphene.ID()

    def resolve_str_(self,info):
        return 'Hello'
    def resolve_int_(self,info):
        return 1
    def resolve_float_(self,info):
        return 1.1
    def resolve_boolean_(self,info):
        return True
    def resolve_id_(self,info):
        return 1.2

    data_ = graphene.Date()
    time_ = graphene.Time()
    date_time = graphene.DateTime()
    decimal_ = graphene.Decimal()

    def resolve_data_(self,info):
        return datetime.date(2050,1,2)
    def resolve_time_(self,info):
        return datetime.time(1,2,3)
    def resolve_date_time(self,info):
        return datetime.datetime(2050,1,2,3,4,5)
    def resolve_decimal_(self,info):
        return decimal.Decimal("10.30")
    
    json_ = graphene.JSONString()
    def resolve_json_(self,info):
        return {"name":"graphql"}
if __name__ =='__main__':
    schema = graphene.Schema(query= Query)
    app = Flask(__name__)
    app.add_url_rule('/graphql',view_func=GraphQLView.as_view('grapql',schema=schema, graphiql=True))
    app.run(debug=True)